package com.spark.core;

import com.spark.tags.SparkTag;

public class SparkBuilder {

	public static String build(XMap xmap, SparkContext context) throws Exception {
		context = context.createInstance();//每个子标签会调用build方法,这个时候context会和外面一层的冲突,所以要克隆一个
		String nameSpace = xmap.getNamespaceURI();
		String result = null;
		String name = xmap.getName();
		SparkConfiguration configuratin = context.getSparkConfiguration();
		if(configuratin!=null){
			SparkTag tag = configuratin.getTag(nameSpace, name);
			if(tag==null) throw new Exception("未找到标签<"+name+">对应的class!");
			tag.init(xmap, context);
			result = tag.execute(xmap, context);
		}
		return result;
	}
}
